package com.stu.fifthtry.controller;


import com.stu.fifthtry.result.Result;
import com.stu.fifthtry.service.SubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import com.stu.fifthtry.pojo.Subject;

@Slf4j
@RestController
@RequestMapping("/subject")
@Api("666")
public class subjectController {
    @Autowired
    private SubjectService subjectService;

    @GetMapping("/{name}")
    public Result<Subject> getByName(@PathVariable String name){
        log.info("查询专业");
        Subject subject=subjectService.getByName(name);
        return Result.success(subject);
    }
    @ApiOperation("manba")
    @DeleteMapping
    public Result delete(@RequestParam String name){
        log.info("删除专业");
        subjectService.delete(name);
        return Result.success();
    }

    @PostMapping
    public Result save(@RequestBody Subject subject){
        log.info("新增专业");
        subjectService.save(subject);
        return Result.success();
    }

    @PutMapping
    public Result update(@RequestBody Subject subject){
        log.info("编辑专业");
        subjectService.update(subject);
        return Result.success();
    }

}
